<!doctype html>
<html xmlns:th="www.thymeleaf.org">
<meta charset="utf-8">
<head th:replace="index::head"></HEAD>
<BODY>
	<header th:replace="index::header"></header>
	<main>
		<div style="padding: 3px 8px">
			<span class="layui-breadcrumb">
				<a href="/">作业论坛首页</a>
				<a :href="'to_list?'+nvl(task,'course.id')">{{nvl(task,'course.name')}}</a>
				<a :href="'to_detail?id='+task.id">{{task.name}}</a>
				<a>
					<cite>说出你的想法</cite>
				</a>
			</span>
		</div>
		<form class="layui-form layui-main" style="width: 800px">
			<div class="layui-form-item layui-form-text">
				<label class="layui-form-label">我想说：</label>
				<div class="layui-input-block">
					<textarea id="demo"></textarea>
				</div>
			</div>
			<div style="text-align: center;">
				<button @click="save" type="button" class="layui-btn">提交</button>
				<button onclick="window.history.back();" type="button" class="layui-btn">返回</button>
			</div>
		</form>
		<load :url="'hwctask/task/get?id='+param('id')"	data="task"></load>
	</main>
	<script>
		var v = new Vue({
			el : "main",
			data : {task:{},comment:{}},
			methods : {
				save(){
					let btn = window.event.srcElement;
					layui.jquery(btn).addClass("layui-btn-disabled");
					this.comment["task.id"] = this.task.id;
					this.comment.content = layedit.getContent(index);
					axios.post("hwcindex/reply",usp(this.comment)).then(res=>{
						if(res.data.code==1){
							location.href="to_detail?id=" + this.task.id;
						} else {
							console.info(res.data);
							alert(res.data.msg);
							layui.jquery(btn).removeClass("layui-btn-disabled");
						}
					});
				}
			}
		});
		var layedit = layui.layedit;
		layedit.set({
			  uploadImage: {
			    url: 'upload' //接口url
			  }
		});
		var index = layedit.build('demo'); //建立编辑器
		layui.element.render();
	</script>
	<!-- 导入页脚 -->
	<footer th:replace="index::footer"></footer>
</BODY>
</HTML>